#include<stdio.h>
#include<string.h>
#include<stdlib.h>

int total(int (*b) [9] ,int row,int list){
    int total=0;
    for(int i = 0; i < row ;i++){
        for(int j = 0; j < list ;j++){
            total+=b[i][j];     
        }    
    }
    printf("和为:%d\n",total);
    return total;
}


int main(void){
    int a[][9]={
        {1,2,3,4,5,6,7,8,9},
        {10,11,12,13,14,15,16,17,18},
        {19,20,21,22,23,24,25,26,27}
    };
    
    int row=sizeof(a)/sizeof(a[0]);
    int list=sizeof(a[0])/sizeof(int);
    int (*b)[9]=(int (*) [9])malloc(sizeof(int (*) [9])*row);
    if(b == NULL){
        printf("malloc err\n");
        return -1;
    }
    for(int i = 0; i < row ;i++){
        b[i]=a[i];
    }
    total(b,row,list);
    free(b);
    b=NULL;
    return 0;
}